package com.hermes.biz.manager.user.impl;


import com.hermes.biz.common.model.result.UserResultDO;
import com.hermes.biz.common.model.user.UserDO;
import com.hermes.biz.dao.user.UserDAO;
import com.hermes.biz.manager.user.UserOperateManager;

public class UserOperateManagerImpl implements UserOperateManager{

	private UserDAO userDAO;
	
	/**
	 * 
	 * @return 
	 */
	public boolean insertNewUser(UserDO user)  {

		return this.userDAO.saveUser(user);
		
	}

	/**
	 * 
	 * return UserResultDO
	 */
	public UserResultDO getSingleUserByUserId(long userId) {
		
		UserDO userDO=userDAO.getUserById(userId);
		UserResultDO userResultDO = new UserResultDO(true);
		
		if(userDO==null){
			userResultDO.setSuccess(false);
			userResultDO.setErrMsg("Not exist !");
		}
		userResultDO.setModule(userDO);
		return userResultDO;
	}

	public UserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	public void updateUser(UserDO user){
		this.userDAO.updateUser(user);
	}
	
	public int updateUserMin(UserDO user){
		return this.userDAO.updateUserMin(user);
	}

	public UserResultDO getSingleUserByUserName(String userName) {
		UserDO userDO = this.userDAO.getUserByName(userName);
	
		UserResultDO userResultDO = new UserResultDO(true);
		userResultDO.setModule(userDO);
		if(userDO==null){
			userResultDO.setSuccess(false);
			userResultDO.setErrMsg("userDO is null");
		}
		return userResultDO;
	}
	

	public void updateUserPassword(UserDO user) {
		this.userDAO.updateUserPassword(user);
	}

	public boolean updateUserLogo(UserDO user) {
		return this.userDAO.updateUserLogo(user);	
	}
	

}
